package com.kadron.favorites;

import com.kadron.dao.KUserFavoritesDAO;
import com.kadron.dao.KUserImageDAO;
import com.kadron.datamodel.KModelCreator;
import com.kadron.entity.UserFavorites;

public class KFavoriteUserModelCreator implements KModelCreator {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6862062071677615532L;

	private KUserFavoritesDAO userFavoritesDAO;
	private KUserImageDAO userImageDAO;
	
	public KFavoriteUserModelCreator(KUserFavoritesDAO userFavoritesDAO, KUserImageDAO userImageDAO) {
		super();
		this.userFavoritesDAO = userFavoritesDAO;
		this.userImageDAO = userImageDAO;
	}
	
	@Override
	public KFavoriteUserModel create(long favId) {
		UserFavorites fav = userFavoritesDAO.find(favId, UserFavorites.class);
		String thumb = userImageDAO.findThumb(fav.getUser().getId());
		KFavoriteUserModel model = new KFavoriteUserModel(favId, fav.getUser().getId(), fav.getUser().getUsername(), fav.getCreated(), fav.getItem().getId(), thumb);
		return model;
	}
	
}
